package br.ronei;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import javax.servlet.ServletContext;

public class FileLineReader {
    private Map<Integer, String> linhas = new HashMap<Integer, String>();
    private int TotalLinhas = 0;

	public FileLineReader(String sArquivo, ServletContext sc) throws FileNotFoundException {
		int linha = 0;
		if (sc != null){
            InputStream is = sc.getResourceAsStream(sArquivo);
            Scanner scanner = new Scanner(is);
            while (scanner.hasNextLine()) {
                linhas.put(linha, scanner.nextLine());
                linha++;
            }
        }
		TotalLinhas = linhas.size();
    }
	public String getLinha(int linha){
		return linhas.get(linha);
	}
	public int getTotalLinhas(){
		return TotalLinhas;
	}
}
